import os
import sys
import logging

# 获取当前文件的绝对路径
current_dir = os.path.dirname(os.path.abspath(__file__))

# 将项目根目录添加到系统路径
sys.path.insert(0, current_dir)

# 配置日志
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    handlers=[
        logging.StreamHandler(),
        logging.FileHandler(os.path.join(current_dir, 'AIPC.log'), encoding='utf-8')
    ]
)

logger = logging.getLogger("AIPC")
logger.info("启动 AIPC 主程序")

if __name__ == "__main__":
    try:
        # 直接启动语音助手作为主程序
        logger.info("启动语音助手作为主程序")
        from voice_assistant.app import main
        main()
    except Exception as e:
        logger.error(f"程序运行出错: {str(e)}")
        import traceback
        logger.error(traceback.format_exc())
        sys.exit(1)